//
// import 'package:flutter/material.dart';
// import 'package:go_router/go_router.dart';
// import 'package:xim/business/model/user.dart';
// import 'package:xim/common/style/colors.dart';
// import 'package:xim/config/route_config.dart';
// import 'package:xim/http/apis.dart';
// import 'package:xim/http/apis/session/session_api.dart';
// import 'package:xim/http/apis/user/user_api.dart';
// import 'package:xim/http/apis/user/user_model.dart';
// import 'package:xim/http/store.dart';
// import 'package:xim/widget/common/state.dart';
// import 'package:xim/widget/common/ui/cell.dart';
//
// /// 用户信息公开页面
// class ProfilePublicPage extends StatefulWidget {
//
//   const ProfilePublicPage({Key? key, required this.account}) : super(key: key);
//
//   final String account;
//
//   @override
//   State<ProfilePublicPage> createState() => _ProfilePublicPageState();
// }
//
// class _ProfilePublicPageState extends AppBarState<ProfilePublicPage>
//     with ShimmerState<ProfilePublicPage>, BrightnessModeState<ProfilePublicPage> {
//
//   late UserInfoModel userInfo;
//
//   ModelColor bgColor = ModelColor(lightColor: const Color(0xffececec), darkColor: const Color(0xff101010));
//   ModelColor fgColor = ModelColor(lightColor: const Color(0xfffefefe), darkColor: const Color(0xff181818));
//   ModelColor userNameColor = ModelColor(lightColor: const Color(0xff191919), darkColor: const Color(0xffd1d1d1));
//   ModelColor accountColor = ModelColor(lightColor: const Color(0xff737373), darkColor: const Color(0xff8c8c8c));
//
//   @override
//   double get elevation => 0;
//
//   @override
//   Color get appBarBgColor => fgColor.color;
//
//   @override
//   IconThemeData get iconTheme => IconThemeData(
//     color: fgColor.reverse
//   );
//
//   late String currUserAccount;
//
//   /// 是否是好友关系
//   bool isFriend = false;
//
//   @override
//   List<ModelColor> get brightnessColors => [bgColor, fgColor,userNameColor,accountColor];
//
//   @override
//   Future<void> initData() async {
//     var info = await UserApi.queryUserInfo(widget.account);
//     /// TODO 添加专门的接口判断是否是好友关系
//     var friends = await UserApi.queryFriends(widget.account);
//     var currAccount = await getUserAccount();
//     setState(() {
//       userInfo = info;
//       currUserAccount = currAccount??'';
//       isFriend = friends
//           .map((e) => e.friendUserInfo.account)
//           .toSet()
//           .contains(info.account);
//     });
//   }
//
//   /// 是否时用户自己
//   bool get isSelf => currUserAccount == userInfo.account;
//
//
//   @override
//   Widget widgetBuild(BuildContext context) {
//     initModelColor(context);
//     var horizontalPadding =  const EdgeInsets.symmetric(horizontal: 16);
//     return Scaffold(
//       appBar: appBar,
//       body: Container(
//         color: bgColor.color,
//         child: Column(
//           mainAxisSize: MainAxisSize.max,
//           children: [
//             Container(
//               color: fgColor.color,
//               padding: EdgeInsets.only(top: 8, bottom: 18.0,left: horizontalPadding.left, right: horizontalPadding.right),
//               child: _userHeader(),
//             ),
//             const SizedBox(height: 12,),
//             Column(
//               children: [
//                 Cell.titleCell(
//                   title: "设置备注", titleStyle: TextStyle(color: userNameColor.color),
//                   decoration: BoxDecoration(color: fgColor.color,),
//                   padding: EdgeInsets.symmetric(horizontal: horizontalPadding.left, vertical: 12),
//                   rightItem: Cell.iconItem(iconData: Icons.chevron_right, iconStyle: IconStyle(size: 14, color: userNameColor.color)),
//                 ),
//                 Cell.titleCell(
//                   title: "更多信息", titleStyle: TextStyle(color: userNameColor.color),
//                   decoration: BoxDecoration(color: fgColor.color,),
//                   padding: EdgeInsets.symmetric(horizontal: horizontalPadding.left, vertical: 12),
//                   rightItem: Cell.iconItem(iconData: Icons.chevron_right, iconStyle: IconStyle(size: 14, color: userNameColor.color)),
//                   onTab: (){
//                     Routers.toDetailProfileInfoPage(userInfo.account);
//                     // Routers.toChat(messageId);
//                   },
//                 ),
//                 Cell.titleCell(
//                   title: "高级", titleStyle: TextStyle(color: userNameColor.color),
//                   decoration: BoxDecoration(color: fgColor.color,),
//                   padding: EdgeInsets.symmetric(horizontal: horizontalPadding.left, vertical: 12),
//                   rightItem: Cell.iconItem(iconData: Icons.chevron_right, iconStyle: IconStyle(size: 14, color: userNameColor.color)),
//                 ),
//                 const SizedBox(height: 18,),
//                 if(isSelf || isFriend) ...[
//                   Container(
//                       color: fgColor.color,
//                       padding: const EdgeInsets.symmetric(vertical: 14),
//                       child: Center(child: Text("发送消息",style: TextStyle(fontSize: 16, color: userNameColor.color)),)
//                   ),
//                   const SizedBox(height: 1,),
//                   Container(
//                       color: fgColor.color,
//                       padding: const EdgeInsets.symmetric(vertical: 14),
//                       child: Center(child: Text("P2P连接",style: TextStyle(fontSize: 16, color: userNameColor.color)),)
//                   )
//                 ],
//                 if(!isSelf && !isFriend)
//                   GestureDetector(
//                     onTap: () async {
//                       // await requestAddFriend(userInfo.account);
//                       UserApi.requestAddFriend(userInfo.account);
//                       toast("好友添加成功");
//                       if(context.mounted) context.pop();
//                     },
//                     child: Container(
//                         color: fgColor.color,
//                         padding: const EdgeInsets.symmetric(vertical: 14),
//                         child: Center(child: Text("添加好友",style: TextStyle(fontSize: 16, color: userNameColor.color)),)
//                     ),
//                   )
//               ],
//             )
//           ],
//         ),
//       ),
//     );
//   }
//
//   Widget _userHeader(){
//     return Row(
//       children: [
//         ClipRRect(
//             borderRadius: const BorderRadius.all(Radius.circular(8)),
//             child: Image.network(userInfo.avatar??'', width: 70,)
//         ),
//         const SizedBox(width: 12,),
//         Column(
//           mainAxisAlignment: MainAxisAlignment.center,
//           crossAxisAlignment: CrossAxisAlignment.start,
//           children: [
//             Text(userInfo.name??'', style: TextStyle(fontSize: 18, color: userNameColor.color),),
//             const SizedBox(height: 8,),
//             Text("账号：${userInfo.account??''}", style: TextStyle(fontSize: 14, color: accountColor.color),),
//             Text("IP：${'成都'}", style: TextStyle(fontSize: 14, color: accountColor.color),),
//           ],
//         )
//       ],
//     );
//   }
//
//   @override
//   String get appBarTitle => "";
// }
